﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GUI.uc_control
{
    public partial class ucThongTinChung : UserControl
    {
        public class column
        {
            public String _name;
            public String _text;
            public bool _visible;

            public column() 
            {
                _name = String.Empty;
                _text = String.Empty;
                _visible = false;
            }

            public column(String name, String text)
            {
                _visible = false;
                _name = name;
                _text = text;
                if (_name != String.Empty && _text != String.Empty)
                    _visible = true;
            }

            public column(String name, String text, bool visible)
            {
                _visible = visible;
                _name = name;
                _text = text;
            }

        }

        public class userdemo
        {
            public String _hoTen;
            public String _dienThoai;
            public float _mucLuong;
            public int _soNgayNghiTrongThang;
            public int _soHangBanTrongThang;

            public userdemo()
            {
                _hoTen = String.Empty;
                _dienThoai = String.Empty;
                _mucLuong = 1000000;
                _soHangBanTrongThang = 0;
                _soNgayNghiTrongThang = 0;
            }

            public userdemo(String hoten, String DienThoai, float mucluong, int ngaynghi, int sohang)
            {
                _hoTen = hoten;
                _dienThoai = DienThoai;
                _mucLuong = mucluong;
                _soHangBanTrongThang = ngaynghi;
                _soNgayNghiTrongThang = sohang;
            }
        }

        column[] _columnList = { 
                                   new column("STT", "STT"),
                                   new column("HoTen", "Ho Ten"),
                                   new column("DienThoai", "Dien Thoai"),
                                   new column("MucLuong", "Muc Luong"),
                                   new column("SoNgayNghiTrongThang", "So Ngay Nghi Trong Thang", false),
                                   new column("SoHangBanTrongThang", "So Hang Ban Trong Thang", false)
                               };

        public ucThongTinChung()
        {
            InitializeComponent();
        }

        private void ucThongTinChung_Load(object sender, EventArgs e)
        {
            Init_Column_List();
            Init_Demo_User_List();
        }

        private void Init_Column_List()
        {
            dataGridView_NhanVien.Rows.Clear();
            dataGridView_NhanVien.Columns.Clear();

            DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
            DataGridViewColumn cl;
            List<String> filterrow = new List<string>();

            for (int i = 0; i < _columnList.Length; i++)
            {
                if (_columnList[i]._visible)
                {
                    cl = new DataGridViewColumn();
                    cl.Name = _columnList[i]._name;
                    cl.HeaderText = _columnList[i]._text;
                    cl.Visible = true;
                    cl.ReadOnly = true;
                    cl.CellTemplate = cell;
                    dataGridView_NhanVien.Columns.Add(cl);
                    filterrow.Add(String.Empty);
                }
            }

            // first row use to filter
            dataGridView_NhanVien.Rows.Add(filterrow.ToArray());
            for (int i = 0; i < dataGridView_NhanVien.Rows[0].Cells.Count; i++)
                dataGridView_NhanVien.Rows[0].Cells[i].ReadOnly = false;
        }

        private void Init_Demo_User_List()
        {
        }
    }
}
